package com.mlink.ai.chat.ads

import android.content.Context
import com.adsdk.android.ads.OxAdSdkManager
import com.adsdk.android.ads.constants.Platform


object AdUtils {

    fun getSplashInterstitialAdConfig(context: Context): AdConfig {
        val platform = OxAdSdkManager.getInstance().getMediationPlatform(context)
        return if (Platform.MAX == platform) {
            AdConfig(
                MaxAdConfig.SPLASH_INTERSTITIAL_AD.adId,
                MaxAdConfig.SPLASH_INTERSTITIAL_AD.adPlacement
            )
        } else {
            AdConfig(
                AdMobAdConfig.SPLASH_INTERSTITIAL_AD.adId,
                AdMobAdConfig.SPLASH_INTERSTITIAL_AD.adPlacement
            )
        }
    }

    fun getMainNativeBannerAdConfig(context: Context): AdConfig {
        val platform = OxAdSdkManager.getInstance().getMediationPlatform(context)
        return if (Platform.MAX == platform) {
            AdConfig(
                MaxAdConfig.MAIN_NATIVE_BANNER_AD.adId,
                MaxAdConfig.MAIN_NATIVE_BANNER_AD.adPlacement
            )
        } else {
            AdConfig(
                AdMobAdConfig.MAIN_NATIVE_BANNER_AD.adId,
                AdMobAdConfig.MAIN_NATIVE_BANNER_AD.adPlacement
            )
        }
    }

    fun getLanguageNativeAdConfig(context: Context): AdConfig {
        val platform = OxAdSdkManager.getInstance().getMediationPlatform(context)
        return if (Platform.MAX == platform) {
            AdConfig(
                MaxAdConfig.LANGUAGE_NATIVE_AD.adId,
                MaxAdConfig.LANGUAGE_NATIVE_AD.adPlacement
            )
        } else {
            AdConfig(
                AdMobAdConfig.LANGUAGE_NATIVE_AD.adId,
                AdMobAdConfig.LANGUAGE_NATIVE_AD.adPlacement
            )
        }
    }

    fun getChatRvAdConfig(context: Context): AdConfig {
        val platform = OxAdSdkManager.getInstance().getMediationPlatform(context)
        return if (Platform.MAX == platform) {
            AdConfig(
                MaxAdConfig.CHAT_RV_AD.adId,
                MaxAdConfig.CHAT_RV_AD.adPlacement
            )
        } else {
            AdConfig(
                AdMobAdConfig.CHAT_RV_AD.adId,
                AdMobAdConfig.CHAT_RV_AD.adPlacement
            )
        }
    }
}

data class AdConfig(val adId: String, val adPlacement: String)

enum class MaxAdConfig(val adId: String, val adPlacement: String) {
    SPLASH_INTERSTITIAL_AD(
        "ee26d7b1dc5cd240",
        "AI Chat_MDM_I"
    ),
    MAIN_NATIVE_BANNER_AD(
        "d316ab5c50e227b2",
        "AI Chat_MDM_NB"
    ),
    LANGUAGE_NATIVE_AD(
        "d9377c13582cc6e8",
        "AI Chat_MDM_N_Language"
    ),
    CHAT_RV_AD(
        "3ab91e107b405eb9",
        "AI Chat_MDM_RV"
    );
}

enum class AdMobAdConfig(val adId: String, val adPlacement: String) {
    SPLASH_INTERSTITIAL_AD(
        "ca-app-pub-6865374070287509/3876498735",
        ""
    ),
    MAIN_NATIVE_BANNER_AD(
        "ca-app-pub-6865374070287509/3042801354",
        ""
    ),
    LANGUAGE_NATIVE_AD(
        "ca-app-pub-6865374070287509/6502662073",
        ""
    ),
    CHAT_RV_AD(
        "ca-app-pub-6865374070287509/3499479816",
        ""
    );
}